package com.example.permission.enums;

import lombok.Getter;

/**
 * 数据状态
 *
 * @author xuwenqian
 */
@Getter
public enum DataStatusEnum {
    /**
     * 状态
     */
    NORMAL(1, "正常"),
    ABNORMAL(2, "删除"),
    ;

    private int code;
    private String name;

    DataStatusEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code获取名称
     *
     * @param code
     * @return
     */
    public static String getNameByCode(int code) {
        DataStatusEnum[] enums = DataStatusEnum.values();
        for (DataStatusEnum e : enums) {
            if (e.getCode() == code) {
                return e.getName();
            }
        }
        return "";
    }
}
